package com.edu.service.impl;

import com.edu.dao.StudentDao;
import com.edu.entity.Student;
import com.edu.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public Student save(Student student) {
        studentDao.save(student);
        return student;
    }

    @Override
    public Student findById(Integer studentId) {
        return studentDao.findById(studentId);
    }

    @Override
    public Student findByStudentNo(String studentNo) {
        return studentDao.findByStudentNo(studentNo);
    }

    @Override
    public List<Student> findAll() {
        return studentDao.findAll();
    }

    @Override
    public Student update(Student student) {
        studentDao.update(student);
        return student;
    }

    @Override
    public void delete(Integer studentId) {
        studentDao.delete(studentId);
    }

    @Override
    public List<Student> search(String keyword) {
        return studentDao.search(keyword);
    }
}